#include "StdAfx.h"
#include "HsmMessageHandler.h"

namespace RoomFW {

HsmMessageHandler::HsmMessageHandler(ActiveObject* parent, QState initialState) :
	QHsm(initialState),
	ActiveObject::MessageHandler(parent),
	messageHandled_(false)
{
	QHsm::init(); // Must initialize QHsm.
}

HsmMessageHandler::~HsmMessageHandler()
{
}

bool HsmMessageHandler::handle(RoomMessageSP message)
{
	messageHandled_ = false;
	currentMessage_ = message;
	QHsm::dispatch(message.get());
	currentMessage_.reset();
	return messageHandled_;
}

RoomMessageSP HsmMessageHandler::getCurrentMessage()
{
	return currentMessage_;
}

void HsmMessageHandler::setMessageHandled()
{
	messageHandled_ = true;
}

}
